<template>
  <div>
    首页
    <br>
    <button @click="addNum">+</button>
    {{ itemNum}}
    <hr>
    {{ userNum }}
    <hr>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  methods: {
    /* addNum () {
      this.$store.commit('items/add_num', 5)
    } */
    addNum () {
      // this['items/add_num'](100)
      this.add_num(100)
    },
    // ...mapMutations(['items/add_num'])
    ...mapMutations('items', ['add_num'])
  },
  computed: {
    ...mapState({
      itemNum: (state) => {
        return state.items.num
      },
      userNum: state => state.user.num
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
